﻿//-----------------------------------------------------------------------
// <copyright file="TypeAdapterFactory.cs" company="ET">
//     Copyright Huirui. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace Huirui.Cavan.Infrastructure.CrossCutting
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    /// <summary>
    /// type adapter factory
    /// </summary>
    public static class TypeAdapterFactory
    {
        #region Members

        /// <summary>
        /// The current type adapter factory
        /// </summary>
        static ITypeAdapterFactory currentTypeAdapterFactory = null;

        #endregion

        #region Public Static Methods

        /// <summary>
        /// Set the current type adapter factory
        /// </summary>
        /// <param name="adapterFactory">The adapter factory to set</param>
        public static void SetCurrent(ITypeAdapterFactory adapterFactory)
        {
            currentTypeAdapterFactory = adapterFactory;
        }

        /// <summary>
        /// Create a new type adapter from currect factory
        /// </summary>
        /// <returns>Created type adapter</returns>
        public static ITypeAdapter CreateAdapter()
        {
            return currentTypeAdapterFactory.Create();
        }

        #endregion
    }
}
